﻿using System;

namespace Demo4.TupleDemo
{
    /// <summary>
    /// 元组常用示例
    /// </summary>
    public class Main
    {
        Main()
        {
            var bob = ("bob", 23);
            Console.WriteLine($"Name: {bob.Item1}, Age: {bob.Item2}"); 
            //元组是值类型
            var bob2 = bob;
            Console.WriteLine($"Name: {bob2.Item1}, Age: {bob2.Item2}");
            //命名元组
            var tuple = (Name: "bob", Age: 23);
            Console.WriteLine($"Name: {tuple.Name}, Age: {tuple.Age}");
            //创建元组
            ValueTuple<string, int> bob3 = ValueTuple.Create("bob", 23);
            (string name, int age) = bob3;
            Console.WriteLine($"name: {name}, age : {age}");
            //元组的比较
            Console.WriteLine($"bob compare bob2 {bob.Equals(bob2)}");
        }

        public static void NewInstance()
        {
            var main = new Main();
        }

    }
}